home *** CD-ROM | disk | FTP | other *** search
/ Aminet 5 / Aminet 5 - March 1995.iso / Aminet / dev / misc / LEDA_gene.lha / LEDA-3.1c-generic / man / point.tex < prev    next >
Encoding:
Text File  |  1994-08-05  |  2.4 KB  |  77 lines

  1. \bigskip
  2. {\magonebf 6.1.1 Points (point)}
  3.  
  4. {\bf 1. Definition}
  5.  
  6. An instance of the data type $point$ is a point in the two-dimensional 
  7. plane $\real^2$. We use $(a,b)$ to denote a point with first (or x-) 
  8. coordinate $a$ and second (or y-) coordinate $b$.
  9.  
  10. \def\name{$point$}
  11. \def\type{$point$}
  12.  
  13. {\bf 2. Creation}
  14.  
  15. a) \create p (double\ x,\ double\ y)
  16.  
  17. b) \create p {}
  18.  
  19.  
  20. introduces a variable \var\ of type \name\ initialized to the point
  21. $(x,y)$. Variant b) initializes \var\ to the point $(0,0)$. 
  22.  
  23.  
  24. \bigskip
  25. {\bf 3. Operations}
  26.  
  27. \smallskip
  28. \+\cleartabs & \hskip 2.5truecm & \hskip 5truecm &\cr
  29. \+\op double    xcoord {}
  30.                            {returns the first coordinate of point $p$}
  31. \smallskip
  32. \+\op double    ycoord {}
  33.                            {returns the second coordinate of point $p$}
  34. \smallskip
  35. \+\op double    distance {point\ q}
  36.                            {returns the euclidean distance between $p$} 
  37. \+\nop                     { and $q$.}
  38. \smallskip
  39. \+\op double    distance {}
  40.                            {returns the euclidean distance between $p$}
  41. \+\nop                     { and $(0,0)$.}
  42. \smallskip
  43. \+\op point   translate {vector\ v} 
  44.                            {returns $p+v$, i.e., $p$ translated by vector}
  45. \+\nop                     {$v$. \precond $v$.dim() = 2.}
  46. \smallskip
  47. \+\op point   translate {double\ \alpha,\ double\ d} {}
  48. \+\nop                     {returns the point created by translating}
  49. \+\nop                     {$p$ in direction $\alpha$ by distance $d$. The} 
  50. \+\nop                     {direction is given by its angle with a}
  51. \+\nop                     {right oriented horizontal ray.}
  52. \smallskip
  53. \+\op point  rotate {point\ q,\ double\ \alpha}
  54.                         {returns the point created by a rotation of $p$}
  55. \+\nop                  {about point $q$ by angle $\alpha$.}
  56. \smallskip
  57. \+\op point  rotate {double\ \alpha}
  58.                         {returns $p$.rotate($point(0,0),\ \alpha$). }
  59.  
  60. \bigskip
  61. {\bf 4. Operators }
  62. \medskip
  63. \+&$bool$     &$point$ ==  $point$     &test for equality\cr
  64. \smallskip
  65. \+&$bool$     &$point$ !=  $point$     &test for inequality\cr
  66. \smallskip
  67. \+&$point$    &$point$ +\  $vector$    &translation by vector\cr
  68.  
  69. \medskip
  70. Input and output operators:
  71. \medskip
  72. \+&$ostream\&$ &$ostream << point$ &writes a point to an output stream\cr
  73. \smallskip
  74. \+&$istream\&$ &$istream >> point$ &reads the coordinates of a point (two doubles)\cr
  75. \+&            &                   &from an input stream\cr
  76.  
  77.